

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>HtmlBlockBuilder - LiterateCS</title>

	<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../bootstrap/css/readable/bootstrap.min.css" />
<link rel="stylesheet" href="../font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../sidebar/sidebar.min.css" />
<link rel="stylesheet" href="../css/book.min.css" />
<link rel="stylesheet" href="../syntax-highlight/solarized-light.min.css" />
<link rel="stylesheet" href="../mermaid/mermaid.css" />

</head>

<body>
    
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#sidebar-toggle" id="sidebar-toggle">
					<span>
						<img src="../images/favicon.ico" height="24" class="hidden-sm hidden-xs" />
						<i id="sidebar-toggle-icon" class="hidden-md hidden-lg hidden-xl fa fa-angle-double-right" aria-hidden="true"></i>
						LiterateCS
					</span>
				</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="../index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
					<li><a href="https://github.com/johtela/LiterateCS"><i class="fa fa-github" aria-hidden="true"></i> GitHub Repository</a></li>
                    <li><a href="https://www.nuget.org/packages/LiterateCS/"><i class="fa fa-download" aria-hidden="true"></i> Download</a></li>
                    <li><a href="../License.html">License</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">
        <div class="row">
            <div id="sidebar" class="col-md-3 hidden-sm hidden-xs">
                
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>On This Page</h4>
            </div>
            <div id="header-menu" class="panel-body main-menu">
                <ul></ul>
            </div>
        </div>  
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>Table of Contents</h4>
            </div>
            <div class="panel-body main-menu">
                <ul>
	<li><a href="../index.html">Home</a></li>
	<ul>
	</ul>
	<li><a href="../Introduction.html">Introduction</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Options.html">Command Line Options</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Program.html">Main Program</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/SplitPath.html">SplitPath Structure</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Weaver.html">Document Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/MdWeaver.html">Markdown Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlWeaver.html">HTML Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/TocManager.html">TOC Manager</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockList.html">Source Blocks</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Macro.html">Macros</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockBuilder.html">Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlBlockBuilder.html" class="selected">HTML Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlGenerator.html">HTML Generation</a></li>
	<ul>
	</ul>
	<li>Themes</li>
	<ul>
<ul>
	<li><a href="../LiterateCS.Theme/DirHelpers.html">Directory Utilities</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Toc.html">Table of Contents Classes</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/PageParams.html">Page Parameters</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Theme.html">Theme Base Class</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/LiterateException.html">Reporting Errors</a></li>
	<ul>
	</ul>
</ul>
	</ul>
	<li><a href="../FrontMatter.html">Front Matter</a></li>
	<ul>
	</ul>
	<li><a href="../TableOfContents.html">Table of Contents File</a></li>
	<ul>
	</ul>
	<li><a href="../TipsAndTricks.html">Tips &amp; Tricks</a></li>
	<ul>
	</ul>
	<li><a href="../License.html">License</a></li>
	<ul>
	</ul>
	<li><a href="../README.html">README</a></li>
	<ul>
	</ul>
	<li><a href="../Installation.html">Installation</a></li>
	<ul>
	</ul>
</ul>
            </div>
        </div>

            </div>
			<div id="contentarea" class="col-md-9 col-sm-12 col-sm-push-0 col-xs-12 col-xs-push-0">
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/BlockBuilder.html">Previous: Block Builder</a></li>
	<li class="next"><a href="../LiterateCS/HtmlGenerator.html">Next: HTML Generation</a></li>
</ul>
				<div id="static-content" class="markdown">
					<h1 id="enriching-code-blocks-in-html-output">Enriching Code Blocks in HTML Output</h1>
<p>When a solution file is used as an input and we are generating HTML output, we
can fully utilize the semantic information provided by Roslyn. We do this by
specializing the <a href="BlockBuilder.html">BlockBuilder</a> class and redefining the way
code blocks are produced.</p>
<p>The basic idea is to add style classes and HTML identifiers to selected tokens
in the code. CSS style sheets defined in the theme control how these attributes
will be actually used. For example, a specific kind of tokens can be colored
differently to distinguish them from other tokens. By adding an ID attribute
to a token, it is possible to use hyperlinks to implement a feature that allows
jumping to a symbol definition. Like in Visual Studio, a tooltip showing the type
of a symbol pops up when you hover over it. This feature relies on the
<a href="http://getbootstrap.com/">Bootstrap</a> framework to provide the tooltip control.</p>
<p>There are probably things we could do to utilize the semantic information even
further. But for documentation purposes, we have the most useful information
now available.</p>
<h2 id="dependencies">Dependencies</h2>
<p>Adding references to Microsoft.CodeAnalysis namespaces bring in the Roslyn
libraries. We also need the System.Web assembly to access the function which
escapes invalid characters in HTML.</p>
<pre class="csharp"><code class="csharp"><span class="keyword" id="LiterateCS">namespace</span> LiterateCS
<span class="punctuation">{</span>
	<span class="keyword">using</span> Microsoft<span class="punctuation">.</span>CodeAnalysis<span class="punctuation">;</span>
	<span class="keyword">using</span> Microsoft<span class="punctuation">.</span>CodeAnalysis<span class="punctuation">.</span>CSharp<span class="punctuation">;</span>
	<span class="keyword">using</span> Microsoft<span class="punctuation">.</span>CodeAnalysis<span class="punctuation">.</span>CSharp<span class="punctuation">.</span>Syntax<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>Collections<span class="punctuation">.</span>Generic<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>IO<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>Linq<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>Web<span class="punctuation">;</span>
	<span class="keyword">using</span> ExtensionCord<span class="punctuation">;</span>

	<span class="keyword" id="LiterateCS.HtmlBlockBuilder">public</span> <span class="keyword">class</span> <span class="typename">HtmlBlockBuilder</span> <span class="punctuation">:</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockBuilder"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder">BlockBuilder</a></span>
	<span class="punctuation">{</span>
</code></pre>
<h2 id="stored-state-variables">Stored State Variables</h2>
<p>We need access to the SemanticModel object that is created when the project
is compiled.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword">private</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">Document</span> <span id="LiterateCS.HtmlBlockBuilder._document">_document</span><span class="punctuation">;</span>
		<span class="keyword">private</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel">SemanticModel</span> <span id="LiterateCS.HtmlBlockBuilder._model">_model</span><span class="punctuation">;</span>
</code></pre>
<p>The hash table below stores the IDs we have assigned thus far. In order not
to define the same ID in multiple places, we consult the hash table before
assigning a new ID. We initialize the hash table inside the constructor.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword">private</span> <span class="typename" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>">HashSet</span><span class="punctuation">&lt;</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation">&gt;</span> <span id="LiterateCS.HtmlBlockBuilder._ids">_ids</span><span class="punctuation">;</span>

		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.HtmlBlockBuilder(LiterateCS.Options)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.HtmlBlockBuilder(LiterateCS.Options)">public</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.HtmlBlockBuilder(LiterateCS.Options)">HtmlBlockBuilder</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Options.html#LiterateCS.Options">Options</a></span> options<span class="punctuation">)</span>
			<span class="punctuation" data-toggle="tooltip" title="void">:</span> <span class="keyword" data-toggle="tooltip" title="void">base</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options">options</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._ids">_ids</a></span> <span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>">=</span> <span class="keyword" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>">new</span> <span class="typename">HashSet</span><span class="punctuation">&lt;</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation">&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>To initialize the HTML block builder we override only the second variant
of the Execute method. We need a Document object provided by MSBuildWorkspace
to get hold of the semantic information. When working with a plain file, this
object is obviously missing. Because the same instance of the class is used to
process all the documents we also clear the ID table. Finally, we call the
inherited method to initialize the fields in the base class.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)">public</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)">override</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)">FromDocument</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">Document</span> document<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._document">_document</a></span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">document</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">document</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document.GetSemanticModelAsync(System.Threading.CancellationToken)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document.GetSemanticModelAsync(System.Threading.CancellationToken)">GetSemanticModelAsync</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel">Result</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._ids">_ids</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Clear()">.</span><span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Clear()">Clear</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.BlockBuilder">base</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.BlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)">.</span><span data-toggle="tooltip" title="LiterateCS.BlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder.FromDocument(Microsoft.CodeAnalysis.Document)">FromDocument</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">document</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="outputting-tokens-and-trivia">Outputting Tokens and Trivia</h2>
<p>The other two methods we need to override are OutputToken and OutputTrivia.
These will be called for each processed token and piece of trivia. Let's
first look at how we handle tokens.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.OutputToken(Microsoft.CodeAnalysis.SyntaxToken)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputToken(Microsoft.CodeAnalysis.SyntaxToken)">protected</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputToken(Microsoft.CodeAnalysis.SyntaxToken)">override</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputToken(Microsoft.CodeAnalysis.SyntaxToken)">OutputToken</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken">SyntaxToken</span> token<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="string">string</span> <span id="href">href</span> <span class="punctuation">=</span> <span class="keyword">null</span><span class="punctuation">;</span>
</code></pre>
<p>First we get the token's string representation and its syntax kind.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="code">code</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken">token</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken.ToString()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken.ToString()">ToString</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">var</span> <span id="kind">kind</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken">token</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken.Kind()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken.Kind()">Kind</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>Next we get the style information for the syntax kind from the
StyleClassForSyntax function. This function effectively implements
the syntax highlighting feature.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="style">style</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">StyleClassForSyntax</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>Then we move up in the AST to get the SyntaxNode under which the token
resides. We retrieve the syntax kind for the node as well.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">var</span> <span id="node">node</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxToken">token</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">Parent</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">var</span> <span id="nodeKind">nodeKind</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode.Kind()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode.Kind()">Kind</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>Now we can use the semantic model to get the symbol information for
the syntax node. There are two helper functions we call that try to
get either ISymbol or ITypeSymbol interface for the node.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">var</span> <span id="symbol">symbol</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)">GetSymbol</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">var</span> <span id="typeSymbol">typeSymbol</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)">GetTypeSymbol</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>If the token kind is identifier, we have a couple of special cases
to handle.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">IdentifierToken</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
</code></pre>
<p>The first case is the <code>var</code> token, which is not classified as a
keyword but as an identifier in the AST. We treat it as a keyword
in the syntax highlighting.</p>
<pre class="csharp"><code class="csharp">				<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">code</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="string" data-toggle="tooltip" title="string">&quot;var&quot;</span><span class="punctuation">)</span>
					<span data-toggle="tooltip" title="string">style</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span class="string" data-toggle="tooltip" title="string">&quot;keyword&quot;</span><span class="punctuation">;</span>
</code></pre>
<p>The next special case to handle is to determine whether the
symbol corresponds to a type name, which should be highlighted
in the code. Visual Studio calls this semantic highlighting
because the decision to highlight the token is not based on the
token kind but rather on the symbol that the token represents.</p>
<pre class="csharp"><code class="csharp">				<span class="keyword">else</span> <span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">IsIdentifier</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">nodeKind</span><span class="punctuation">)</span><span class="punctuation">)</span>
				<span class="punctuation">{</span>
					<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)">IsHighightedTypeName</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation">)</span>
						<span data-toggle="tooltip" title="string">style</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span class="string" data-toggle="tooltip" title="string">&quot;typename&quot;</span><span class="punctuation">;</span>
</code></pre>
<p>While figuring out the type of an identifier type we can
also check whether it is clickable. That is, whether we
add a hyperlink to it.</p>
<pre class="csharp"><code class="csharp">					<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)">IsReferenceableSymbol</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">)</span>
						<span data-toggle="tooltip" title="string">href</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetHrefForSymbol(Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetHrefForSymbol(Microsoft.CodeAnalysis.ISymbol)">GetHrefForSymbol</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span class="punctuation">}</span>
				<span class="keyword">else</span> <span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">IsHighlightedDeclaration</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">nodeKind</span><span class="punctuation">)</span><span class="punctuation">)</span>
					<span data-toggle="tooltip" title="string">style</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span class="string" data-toggle="tooltip" title="string">&quot;typename&quot;</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
</code></pre>
<p>To enable jumping to a symbol definition, we get the Id for the symbol.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="id">id</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSyntaxNodeId(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetSyntaxNodeId(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">GetSyntaxNodeId</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>Finally, we get the type information that can be shown in a tooltip.
After that we collect all the information gathered and call
OutputDecoratedCode to spit out the token with all of its associated
attributes.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="tooltip">tooltip</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTooltip(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetTooltip(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">GetTooltip</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)">OutputDecoratedCode</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">code</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">style</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">id</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">href</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">tooltip</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>Outputting trivia is a considerably simpler endeavor. We just convert the
trivia to string and output it with possible style class for syntax
highlighting. Typically trivia represent comments and whitespace, but
preprocessor directives are inside trivia too. We like to have a different
style for those.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.OutputTrivia(Microsoft.CodeAnalysis.SyntaxTrivia)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputTrivia(Microsoft.CodeAnalysis.SyntaxTrivia)">protected</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputTrivia(Microsoft.CodeAnalysis.SyntaxTrivia)">override</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputTrivia(Microsoft.CodeAnalysis.SyntaxTrivia)">OutputTrivia</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia">SyntaxTrivia</span> trivia<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="string">var</span> code <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia">trivia</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia.ToString()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia.ToString()">ToString</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)">OutputDecoratedCode</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">code</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">StyleClassForSyntax</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia">trivia</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia.Kind()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTrivia.Kind()">Kind</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">,</span>
				<span class="keyword">null</span><span class="punctuation">,</span> <span class="keyword">null</span><span class="punctuation">,</span> <span class="keyword">null</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="helper-functions">Helper Functions</h2>
<p>The rest of the methods are private helper functions that are used by the
two methods defined above. The first two helper functions return symbol
information for a node. They try to get ISymbol or ITypeSymbold interfaces
using various methods provided by Roslyn. If they fail, null is returned.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)">private</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)">GetSymbol</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">SyntaxNode</span> node<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">?</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">:</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">GetSymbolInfo</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">Symbol</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">??</span>
					<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetDeclaredSymbol(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetDeclaredSymbol(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">GetDeclaredSymbol</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">??</span>
					<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetPreprocessingSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetPreprocessingSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode)">GetPreprocessingSymbolInfo</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.IPreprocessingSymbol">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.IPreprocessingSymbol">Symbol</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">??</span>
					<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetSymbolInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">GetSymbolInfo</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol>">.</span><span data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol>">CandidateSymbols</span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol>.FirstOrDefault<Microsoft.CodeAnalysis.ISymbol>()">.</span><span data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol>.FirstOrDefault<Microsoft.CodeAnalysis.ISymbol>()">FirstOrDefault</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbol(Microsoft.CodeAnalysis.SyntaxNode)">;</span>

		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)">private</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">ITypeSymbol</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)">GetTypeSymbol</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">SyntaxNode</span> node<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._model">_model</a></span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">?</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetTypeInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SemanticModel.GetTypeInfo(Microsoft.CodeAnalysis.SyntaxNode, System.Threading.CancellationToken)">GetTypeInfo</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">Type</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)">;</span>
</code></pre>
<p>The function below is used by the semantic highlighting feature. It
determines whether a symbol represents a type that should be highlighted.
As in Visual Studio we highlight class, struct, or delegate names, as
well as attribute names, which are actually methods in the symbol table.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)">private</span> <span class="keyword" data-toggle="tooltip" title="bool">bool</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)">IsHighightedTypeName</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">SyntaxNode</span> node<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
			<span class="punctuation" data-toggle="tooltip" title="bool">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">NamedType</span> <span class="punctuation" data-toggle="tooltip" title="bool">||</span>
			 <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">TypeParameter</span> <span class="punctuation" data-toggle="tooltip" title="bool">||</span>
			 <span class="punctuation" data-toggle="tooltip" title="bool">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">Parent</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode.Kind()">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode.Kind()">Kind</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">Attribute</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Method</span><span class="punctuation" data-toggle="tooltip" title="bool">)</span><span class="punctuation" data-toggle="tooltip" title="bool">)</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighightedTypeName(Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SyntaxNode)">;</span>
</code></pre>
<p>To enable jumping to a symbol definition we need to provide an ID for a
token. This is done just by taking the symbol name. If the same symbol name
is already defined elsewhere, we return null. The check is needed because
Roslyn usually returns the same symbol information for several consecutive
tokens (since they reside under same syntax node). We effectively anchor the
first token with the given symbol name.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetSyntaxNodeId(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSyntaxNodeId(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">private</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSyntaxNodeId(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">GetSyntaxNodeId</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">SyntaxNode</span> node<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
				<span class="punctuation" data-toggle="tooltip" title="bool">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span> <span class="keyword" data-toggle="tooltip" title="bool">is</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax">MemberDeclarationSyntax</span> <span class="punctuation" data-toggle="tooltip" title="bool">||</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span> <span class="keyword" data-toggle="tooltip" title="bool">is</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax">VariableDeclaratorSyntax</span><span class="punctuation" data-toggle="tooltip" title="bool">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="symbolStr">symbolStr</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)">GetSymbolId</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span class="keyword">if</span> <span class="punctuation">(</span><span class="punctuation" data-toggle="tooltip" title="bool">!</span><span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._ids">_ids</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Contains(string)">.</span><span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Contains(string)">Contains</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">symbolStr</span><span class="punctuation">)</span><span class="punctuation">)</span>
				<span class="punctuation">{</span>
					<span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._ids">_ids</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Add(string)">.</span><span data-toggle="tooltip" title="System.Collections.Generic.HashSet<string>.Add(string)">Add</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">symbolStr</span><span class="punctuation">)</span><span class="punctuation">;</span>
					<span class="keyword">return</span> <span data-toggle="tooltip" title="string">symbolStr</span><span class="punctuation">;</span>
				<span class="punctuation">}</span>
			<span class="punctuation">}</span>
			<span class="keyword">return</span> <span class="keyword">null</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>The mirror operation of defining an ID is making a token clickable by
surrounding it with an <code>&lt;a&gt;</code> tag. The target of the link is in the <code>href</code>
attribute, which is determined by the function below. The link consists
of the relative file path and the ID inside the file. The file path is
always used, even if the link target is inside the same file.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetHrefForSymbol(Microsoft.CodeAnalysis.ISymbol)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetHrefForSymbol(Microsoft.CodeAnalysis.ISymbol)">private</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetHrefForSymbol(Microsoft.CodeAnalysis.ISymbol)">GetHrefForSymbol</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxReference">var</span> <span id="sref">sref</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>">.</span><span data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>">DeclaringSyntaxReferences</span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>.First<Microsoft.CodeAnalysis.SyntaxReference>()">.</span><span data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>.First<Microsoft.CodeAnalysis.SyntaxReference>()">First</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="LiterateCS.SplitPath">var</span> <span id="reffile">reffile</span> <span class="punctuation">=</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath.Split(string, string)">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath.Split(string, string)"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.Split(string, string)">Split</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder._options">_options</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/Options.html#LiterateCS.Options.InputPath">InputPath</a></span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.BasePath">BasePath</a></span><span class="punctuation">,</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxReference">sref</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTree">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxTree">SyntaxTree</span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string">FilePath</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="LiterateCS.SplitPath">var</span> <span id="inputfile">inputfile</span> <span class="punctuation">=</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath.Split(string, string)">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath.Split(string, string)"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.Split(string, string)">Split</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder._options">_options</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/Options.html#LiterateCS.Options.InputPath">InputPath</a></span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.BasePath">BasePath</a></span><span class="punctuation">,</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._document">_document</a></span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string">FilePath</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span class="typename" data-toggle="tooltip" title="System.IO.Path">Path</span><span class="punctuation" data-toggle="tooltip" title="System.IO.Path.Combine(string, string)">.</span><span data-toggle="tooltip" title="System.IO.Path.Combine(string, string)">Combine</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">inputfile</span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.RelativePathToRoot">RelativePathToRoot</a></span><span class="punctuation">,</span>
				<span data-toggle="tooltip" title="LiterateCS.SplitPath">reffile</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath.ChangeExtension(string)">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath.ChangeExtension(string)"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.ChangeExtension(string)">ChangeExtension</a></span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;html&quot;</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.FilePath">FilePath</a></span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="string.Replace(char, char)">.</span><span data-toggle="tooltip" title="string.Replace(char, char)">Replace</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="char">&#39;\\&#39;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="char">&#39;/&#39;</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="string">+</span>
				<span class="string" data-toggle="tooltip" title="string">&quot;#&quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">+</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)">GetSymbolId</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>To generate the link Id from the symbol we use <code>ToDisplayString</code> method,
that let's you specify in great detail which parts of the symbol included
in the result. We just need to make sure that the Id is unique, so we
pick the parts that distinguish the symbol from the others. We always
use the original definition of the symbol. This means that if a symbol
is an instantiation of generic type or method, we refer to its definition
instead of the specific instance.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">readonly</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayFormat">SymbolDisplayFormat</span> <span id="LiterateCS.HtmlBlockBuilder._symbolDisplayFormat">_symbolDisplayFormat</span> <span class="punctuation">=</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayFormat">new</span> <span class="typename">SymbolDisplayFormat</span> <span class="punctuation">(</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGlobalNamespaceStyle">SymbolDisplayGlobalNamespaceStyle</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGlobalNamespaceStyle">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGlobalNamespaceStyle">Omitted</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayTypeQualificationStyle">SymbolDisplayTypeQualificationStyle</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayTypeQualificationStyle">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayTypeQualificationStyle">NameAndContainingTypesAndNamespaces</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGenericsOptions">SymbolDisplayGenericsOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGenericsOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayGenericsOptions">IncludeTypeParameters</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">SymbolDisplayMemberOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">IncludeContainingType</span> <span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">|</span> 
					<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">SymbolDisplayMemberOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMemberOptions">IncludeParameters</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayDelegateStyle">SymbolDisplayDelegateStyle</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayDelegateStyle">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayDelegateStyle">NameAndSignature</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayExtensionMethodStyle">SymbolDisplayExtensionMethodStyle</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayExtensionMethodStyle">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayExtensionMethodStyle">StaticMethod</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayParameterOptions">SymbolDisplayParameterOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayParameterOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayParameterOptions">IncludeType</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayPropertyStyle">SymbolDisplayPropertyStyle</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayPropertyStyle">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayPropertyStyle">NameOnly</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayLocalOptions">SymbolDisplayLocalOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayLocalOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayLocalOptions">None</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayKindOptions">SymbolDisplayKindOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayKindOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayKindOptions">None</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions">SymbolDisplayMiscellaneousOptions</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions">UseSpecialTypes</span><span class="punctuation">)</span><span class="punctuation">;</span>

		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)">private</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetSymbolId(Microsoft.CodeAnalysis.ISymbol)">GetSymbolId</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">return</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">OriginalDefinition</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat)">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol.ToDisplayString(Microsoft.CodeAnalysis.SymbolDisplayFormat)">ToDisplayString</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolDisplayFormat"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder._symbolDisplayFormat">_symbolDisplayFormat</a></span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>Tooltip is a handy way for showing additional information in code blocks
without cluttering them excessively. Again, we mimic Visual Studio and
use a tooltip to show the type of a symbol.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.GetTooltip(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTooltip(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">private</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTooltip(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.ISymbol)">GetTooltip</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">SyntaxNode</span> node<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">var</span> typeSymbol <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder.GetTypeSymbol(Microsoft.CodeAnalysis.SyntaxNode)">GetTypeSymbol</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SyntaxNode">node</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="title">title</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">typeSymbol</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ITypeSymbol">typeSymbol</span><span class="punctuation" data-toggle="tooltip" title="object.ToString()">.</span><span data-toggle="tooltip" title="object.ToString()">ToString</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Method</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span>
					<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="object.ToString()">.</span><span data-toggle="tooltip" title="object.ToString()">ToString</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
					<span class="keyword">null</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span data-toggle="tooltip" title="string">title</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
				<span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object)">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot; data-toggle=\&quot;tooltip\&quot; title=\&quot;{0}\&quot;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">title</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>Before we can attach a link to a token, we need to check if we have it
defined somewhere in the solution. External references are not navigable.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)">private</span> <span class="keyword" data-toggle="tooltip" title="bool">bool</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)">IsReferenceableSymbol</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">ISymbol</span> symbol<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
			<span class="punctuation" data-toggle="tooltip" title="bool">!</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Kind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind.In<Microsoft.CodeAnalysis.SymbolKind>(params Microsoft.CodeAnalysis.SymbolKind[])">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind.In<Microsoft.CodeAnalysis.SymbolKind>(params Microsoft.CodeAnalysis.SymbolKind[])">In</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Local</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Parameter</span><span class="punctuation">,</span> 
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">Namespace</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">SymbolKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.SymbolKind">RangeVariable</span><span class="punctuation">)</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
			<span class="punctuation" data-toggle="tooltip" title="bool">!</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.ISymbol">symbol</span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>">.</span><span data-toggle="tooltip" title="System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SyntaxReference>">DeclaringSyntaxReferences</span><span class="punctuation" data-toggle="tooltip" title="bool">.</span><span data-toggle="tooltip" title="bool">IsEmpty</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsReferenceableSymbol(Microsoft.CodeAnalysis.ISymbol)">;</span>
</code></pre>
<p>The following pair of functions helps determining whether a syntax
kind represents an identifier or a type definition that should be
highlighted.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">private</span> <span class="keyword" data-toggle="tooltip" title="bool">bool</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">IsIdentifier</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span> kind<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind.In<Microsoft.CodeAnalysis.CSharp.SyntaxKind>(params Microsoft.CodeAnalysis.CSharp.SyntaxKind[])">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind.In<Microsoft.CodeAnalysis.CSharp.SyntaxKind>(params Microsoft.CodeAnalysis.CSharp.SyntaxKind[])">In</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">IdentifierName</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">GenericName</span><span class="punctuation">,</span> 
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">TypeParameter</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsIdentifier(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">;</span>

		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">private</span> <span class="keyword" data-toggle="tooltip" title="bool">bool</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">IsHighlightedDeclaration</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span> kind<span class="punctuation">)</span> <span class="punctuation">=&gt;</span>
			<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind.In<Microsoft.CodeAnalysis.CSharp.SyntaxKind>(params Microsoft.CodeAnalysis.CSharp.SyntaxKind[])">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind.In<Microsoft.CodeAnalysis.CSharp.SyntaxKind>(params Microsoft.CodeAnalysis.CSharp.SyntaxKind[])">In</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">ClassDeclaration</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">StructDeclaration</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">EnumDeclaration</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">EventDeclaration</span><span class="punctuation">,</span>
				<span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">DelegateDeclaration</span><span class="punctuation">)</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.IsHighlightedDeclaration(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">;</span>
</code></pre>
<p>Syntax highlighting is based primarily just on a kind of a token. There
are literally hundreds of different token kinds. The main job of the
function below is to check whether the specified syntax kind lies within
a recognized range. If it does not match any of them, null is returned.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">private</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.StyleClassForSyntax(Microsoft.CodeAnalysis.CSharp.SyntaxKind)">StyleClassForSyntax</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span> kind<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&gt;=</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">TildeToken</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span> <span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&lt;</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">BoolKeyword</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;punctuation&quot;</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&gt;=</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">BoolKeyword</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&lt;</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">InterpolatedStringStartToken</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;keyword&quot;</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&gt;=</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SingleLineCommentTrivia</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&lt;=</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">MultiLineCommentTrivia</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;comment&quot;</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&gt;=</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">PreprocessingMessageTrivia</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span>
				<span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">&lt;</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">XmlElement</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;preprocessor&quot;</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">StringLiteralToken</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;string&quot;</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">kind</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">SyntaxKind</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.CSharp.SyntaxKind">NumericLiteralToken</span><span class="punctuation">)</span>
				<span class="keyword">return</span> <span class="string" data-toggle="tooltip" title="string">&quot;number&quot;</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span class="keyword">null</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>At last we can actually output the token or trivia to the output file.
This is done using the inherited AppendCode function. But before we
call it, we combine all the attributes and extra information we collected
for the token into HTML tags and attributes.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder.OutputDecoratedCode(string, string, string, string, string)">OutputDecoratedCode</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span> code<span class="punctuation">,</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> style<span class="punctuation">,</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> id<span class="punctuation">,</span>
			<span class="keyword" data-toggle="tooltip" title="string">string</span> href<span class="punctuation">,</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> attrs<span class="punctuation">)</span>
		<span class="punctuation">{</span>
</code></pre>
<p>Now we also need the HttpUtility class to encode the characters reserved
by HTML into escape codes.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="escaped">escaped</span> <span class="punctuation">=</span> <span class="typename" data-toggle="tooltip" title="System.Web.HttpUtility">HttpUtility</span><span class="punctuation" data-toggle="tooltip" title="System.Web.HttpUtility.HtmlEncode(string)">.</span><span data-toggle="tooltip" title="System.Web.HttpUtility.HtmlEncode(string)">HtmlEncode</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">code</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>Surround with <code>&lt;a&gt;</code> tag, if href is given.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="output">output</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="string">href</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span>
				<span data-toggle="tooltip" title="string">escaped</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
				<span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object, object)">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;&lt;a href=\&quot;{0}\&quot;&gt;{1}&lt;/a&gt;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">href</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">escaped</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>We only add a <code>&lt;span&gt;</code> tag if at least one of the provided parameters
is not null.</p>
<pre class="csharp"><code class="csharp">			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">style</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span> <span data-toggle="tooltip" title="string">id</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;&amp;</span> <span data-toggle="tooltip" title="string">attrs</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span><span class="punctuation">)</span>
				<span data-toggle="tooltip" title="LiterateCS.BlockBuilder.AppendCode(string)"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder.AppendCode(string)">AppendCode</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">output</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">else</span>
			<span class="punctuation">{</span>
</code></pre>
<p>Surround the code with a <code>&lt;span&gt;</code> tag, and with all the given
attributes.</p>
<pre class="csharp"><code class="csharp">				<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="idText">idText</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="string">id</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span> <span class="string" data-toggle="tooltip" title="string">&quot;&quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
					<span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object)">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot; id=\&quot;{0}\&quot;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">id</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="styleText">styleText</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="string">style</span> <span class="punctuation" data-toggle="tooltip" title="bool">==</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="string">?</span> <span class="string" data-toggle="tooltip" title="string">&quot;&quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">:</span>
					<span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object)">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot; class=\&quot;{0}\&quot;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">style</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.BlockBuilder.AppendCode(string)"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder.AppendCode(string)">AppendCode</a></span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, params object[])">.</span><span data-toggle="tooltip" title="string.Format(string, params object[])">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;&lt;span{0}{1}{2}&gt;{3}&lt;/span&gt;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">styleText</span><span class="punctuation">,</span>
					<span data-toggle="tooltip" title="string">idText</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">attrs</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">output</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
		<span class="punctuation">}</span>
	<span class="punctuation">}</span>
<span class="punctuation">}</span>
</code></pre>

				</div>
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/BlockBuilder.html">Previous: Block Builder</a></li>
	<li class="next"><a href="../LiterateCS/HtmlGenerator.html">Next: HTML Generation</a></li>
</ul>
			</div>
        </div>
    </div>
    
    <footer class="panel-footer text-center">
        <div align="center">Copyright © 2018 Tommi Johtela</div>
		<div align="right">
			<small>
				Documentation created with <a href="https://johtela.github.io/LiterateCS/">LiterateCS</a>.
			</small>
		</div>
    </footer>


    
    <script src="../bootstrap/js/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../sidebar/sidebar.js"></script>
    <script src="../syntax-highlight/syntax.js"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
        extensions: ["jsMath2jax.js"]
        });
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML'></script>
	<script src="../mermaid/mermaid.min.js"></script>
	<script>mermaid.initialize({startOnLoad:true});</script>

</body>
</html>